From: Brion Vibber Date: Mon, 21 Feb 2005 12:46:37 +0000 (+0000) Subject: Cruft war continues: more uses of isAnon() and isLoggedIn() X-Git-Tag: 1.5.0alpha1~705 X-Git-Url: http://git.cyclocoop.org/%27%20.%20%24prefix%20.%20Wiki::transformTitleToURI%28%24matches%5B1%5D%29%20.%20%27?a=commitdiff_plain;h=014a1d1bab9f1ca1f744723704fb07c3dd531a5b;p=lhc%2Fweb%2Fwiklou.git Cruft war continues: more uses of isAnon() and isLoggedIn() --- diff --git a/includes/Article.php b/includes/Article.php index d869c8b066..b8f603ffa6 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -675,7 +675,7 @@ class Article { $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); # If we have been passed an &rcid= parameter, we want to give the user a # chance to mark this new article as patrolled. - if ( $wgUseRCPatrol && !is_null ( $rcid ) && $rcid != 0 && $wgUser->getID() != 0 && + if ( $wgUseRCPatrol && !is_null ( $rcid ) && $rcid != 0 && $wgUser->isLoggedIn() && ( $wgUser->isAllowed('patrol') || !$wgOnlySysopsCanPatrol ) ) { $wgOut->addHTML( wfMsg ( 'markaspatrolledlink', @@ -721,7 +721,7 @@ class Article { $won = wfInvertTimestamp( $now ); wfSeedRandom(); $rand = wfRandom(); - $isminor = ( $isminor && $wgUser->getID() ) ? 1 : 0; + $isminor = ( $isminor && $wgUser->isLoggedIn() ) ? 1 : 0; $mungedText = $text; $flags = Revision::compressRevisionText( $mungedText ); @@ -915,7 +915,7 @@ class Article { $good = true; if ( $this->mMinorEdit ) { $me1 = 1; } else { $me1 = 0; } - if ( $minor && $wgUser->getID() ) { $me2 = 1; } else { $me2 = 0; } + if ( $minor && $wgUser->isLoggedIn() ) { $me2 = 1; } else { $me2 = 0; } if ( $this->isRedirect( $text ) ) { # Remove all content but redirect # This could be done by reconstructing the redirect from a title given by @@ -1097,7 +1097,7 @@ class Article { $wgOut->errorpage( 'rcpatroldisabled', 'rcpatroldisabledtext' ); return; } - if ( $wgUser->getID() == 0 ) + if ( $wgUser->isAnon() ) { $wgOut->loginToUse(); return; @@ -1132,7 +1132,7 @@ class Article { global $wgUser, $wgOut; - if ( 0 == $wgUser->getID() ) { + if ( $wgUser->isAnon() ) { $wgOut->errorpage( 'watchnologin', 'watchnologintext' ); return; } @@ -1167,7 +1167,7 @@ class Article { global $wgUser, $wgOut; - if ( 0 == $wgUser->getID() ) { + if ( $wgUser->isAnon() ) { $wgOut->errorpage( 'watchnologin', 'watchnologintext' ); return; } @@ -1902,7 +1902,7 @@ class Article { return $wgUseFileCache and (!$wgShowIPinHeader) and ($this->getID() != 0) - and ($wgUser->getId() == 0) + and ($wgUser->isAnon()) and (!$wgUser->getNewtalk()) and ($this->mTitle->getNamespace() != NS_SPECIAL ) and (empty( $action ) || $action == 'view') diff --git a/includes/ChangesList.php b/includes/ChangesList.php index 887e6e15e9..57498153e3 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -328,7 +328,7 @@ class ChangesList { $curIdEq = 'curid=' . $rc_cur_id; # Should patrol-related stuff be shown? - $unpatrolled = $wgUseRCPatrol && $wgUser->getID() != 0 && + $unpatrolled = $wgUseRCPatrol && $wgUser->isLoggedIn() && ( !$wgOnlySysopsCanPatrol || $wgUser->isAllowed('patrol') ) && $rc_patrolled == 0; # Make date header if necessary @@ -489,7 +489,7 @@ class ChangesList { } # Should patrol-related stuff be shown? - if ( $wgUseRCPatrol && $wgUser->getID() != 0 && + if ( $wgUseRCPatrol && $wgUser->isLoggedIn() && ( !$wgOnlySysopsCanPatrol || $wgUser->isAllowed('patrol') )) { $rc->unpatrolled = !$rc_patrolled; } else { diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index 603fadf1a2..767c736d5e 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -123,7 +123,7 @@ class DifferenceEngine { } else { $rollback = ''; } - if ( $wgUseRCPatrol && $this->mRcidMarkPatrolled != 0 && $wgUser->getID() != 0 && + if ( $wgUseRCPatrol && $this->mRcidMarkPatrolled != 0 && $wgUser->isLoggedIn() && ( $wgUser->isAllowed('rollback') || !$wgOnlySysopsCanPatrol ) ) { $patrol = ' [' . $sk->makeKnownLinkObj( $wgTitle, wfMsg( 'markaspatrolleddiff' ), diff --git a/includes/EditPage.php b/includes/EditPage.php index 2cd0bdc429..be5d659c90 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -156,7 +156,7 @@ class EditPage { $this->blockedIPpage(); return; } - if ( !$wgUser->getID() && $wgWhitelistEdit ) { + if ( $wgUser->isAnon() && $wgWhitelistEdit ) { $this->userNotLoggedInPage(); return; } @@ -249,7 +249,7 @@ class EditPage { */ function tokenOk( &$request ) { global $wgUser; - if( $wgUser->getId() == 0 ) { + if( $wgUser->isAnon() ) { # Anonymous users may not have a session # open. Don't tokenize. return true; @@ -318,7 +318,7 @@ class EditPage { $this->blockedIPpage(); return; } - if ( !$wgUser->getID() && $wgWhitelistEdit ) { + if ( $wgUser->isAnon() && $wgWhitelistEdit ) { $this->userNotLoggedInPage(); return; } @@ -541,7 +541,7 @@ class EditPage { $minoredithtml = ''; - if ( 0 != $wgUser->getID() || $wgAllowAnonymousMinor ) { + if ( $wgUser->isLoggedIn() || $wgAllowAnonymousMinor ) { $minoredithtml = "minoredit?" checked='checked'":""). " accesskey='".wfMsg('accesskey-minoredit')."' id='wpMinoredit' />". @@ -550,7 +550,7 @@ class EditPage { $watchhtml = ''; - if ( 0 != $wgUser->getID() ) { + if ( $wgUser->isLoggedIn() ) { $watchhtml = "watchthis?" checked='checked'":""). " accesskey='".wfMsg('accesskey-watch')."' id='wpWatchthis' />". ""; @@ -663,7 +663,7 @@ END section ) . "\" name=\"wpSection\" /> edittime}\" name=\"wpEdittime\" />\n" ); - if ( 0 != $wgUser->getID() ) { + if ( $wgUser->isLoggedIn() ) { /** * To make it harder for someone to slip a user a page * which submits an edit form to the wiki without their @@ -770,7 +770,7 @@ END * @todo document */ function userNotLoggedInPage() { - global $wgOut, $wgUser; + global $wgOut; $wgOut->setPageTitle( wfMsg( 'whitelistedittitle' ) ); $wgOut->setRobotpolicy( 'noindex,nofollow' ); diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 8e4937f9d6..3d66a27735 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -302,7 +302,7 @@ function logProfilingData() { $forward .= ' from ' . $_SERVER['HTTP_FROM']; if( $forward ) $forward = "\t(proxied via {$_SERVER['REMOTE_ADDR']}{$forward})"; - if($wgUser->getId() == 0) + if( $wgUser->isAnon() ) $forward .= ' anon'; $log = sprintf( "%s\t%04.3f\t%s\n", gmdate( 'YmdHis' ), $elapsed, diff --git a/includes/ImagePage.php b/includes/ImagePage.php index cec8bd0d5d..105eb895e9 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -368,7 +368,7 @@ class ImagePage extends Article { $wgOut->readOnlyPage(); return; } - if( $wgUser->getId() == 0 ) { + if( $wgUser->isAnon() ) { $wgOut->errorpage( 'uploadnologin', 'uploadnologintext' ); return; } diff --git a/includes/SpecialEmailuser.php b/includes/SpecialEmailuser.php index 8845e93735..7bb4a6177a 100644 --- a/includes/SpecialEmailuser.php +++ b/includes/SpecialEmailuser.php @@ -18,7 +18,7 @@ function wfSpecialEmailuser( $par ) { return; } - if ( 0 == $wgUser->getID() || + if ( $wgUser->isAnon() || ( !$wgUser->isValidEmailAddr( $wgUser->getEmail() ) ) ) { $wgOut->errorpage( "mailnologin", "mailnologintext" ); return; diff --git a/includes/SpecialMakesysop.php b/includes/SpecialMakesysop.php index aa062839c2..96b87635c0 100644 --- a/includes/SpecialMakesysop.php +++ b/includes/SpecialMakesysop.php @@ -20,7 +20,7 @@ require_once( "LinksUpdate.php" ); function wfSpecialMakesysop() { global $wgUser, $wgOut, $wgRequest; - if ( 0 == $wgUser->getID() or $wgUser->isBlocked() ) { + if ( $wgUser->isAnon() or $wgUser->isBlocked() ) { $wgOut->errorpage( "movenologin", "movenologintext" ); return; } diff --git a/includes/SpecialNewpages.php b/includes/SpecialNewpages.php index a8935ec811..ca85ec4b7f 100644 --- a/includes/SpecialNewpages.php +++ b/includes/SpecialNewpages.php @@ -29,7 +29,7 @@ class NewPagesPage extends QueryPage { function getSQL() { global $wgUser, $wgOnlySysopsCanPatrol, $wgUseRCPatrol; - $usepatrol = ( $wgUseRCPatrol && $wgUser->getID() != 0 && + $usepatrol = ( $wgUseRCPatrol && $wgUser->isLoggedIn() && ( $wgUser->isAllowed('patrol') || !$wgOnlySysopsCanPatrol ) ) ? 1 : 0; $dbr =& wfGetDB( DB_SLAVE ); extract( $dbr->tableNames( 'recentchanges', 'page', 'text' ) ); @@ -75,7 +75,7 @@ class NewPagesPage extends QueryPage { # Since there is no diff link, we need to give users a way to # mark the article as patrolled if it isn't already if ( $wgUseRCPatrol && !is_null ( $result->usepatrol ) && $result->usepatrol && - $result->patrolled == 0 && $wgUser->getID() != 0 && + $result->patrolled == 0 && $wgUser->isLoggedIn() && ( $wgUser->isAllowed('patrol') || !$wgOnlySysopsCanPatrol ) ) $link = $skin->makeKnownLink( $result->title, '', "rcid={$result->rcid}" ); else diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index e2c16f6c80..bfbe8f466a 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -103,7 +103,7 @@ class PreferencesForm { function execute() { global $wgUser, $wgOut, $wgUseDynamicDates; - if ( 0 == $wgUser->getID() ) { + if ( $wgUser->isAnon() ) { $wgOut->errorpage( 'prefsnologin', 'prefsnologintext' ); return; } diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index 7abf0aa34b..50407ee19c 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -486,7 +486,7 @@ class LoginForm { global $wgEmailAuthentication; if ( '' == $this->mName ) { - if ( 0 != $wgUser->getID() ) { + if ( $wgUser->isLoggedIn() ) { $this->mName = $wgUser->getName(); } else { $this->mName = @$_COOKIE[$wgDBname.'UserName']; @@ -511,7 +511,7 @@ class LoginForm { $template->set( 'action', $titleObj->getLocalUrl( $q ) ); $template->set( 'error', $err ); $template->set( 'create', $wgUser->isAllowedToCreateAccount() ); - $template->set( 'createemail', $wgEnableEmail && ($wgUser->getID() != 0) ); + $template->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() ); $template->set( 'userealname', $wgAllowRealName ); $template->set( 'useemail', $wgEnableEmail ); $template->set( 'useemailauthent', $wgEmailAuthentication ); diff --git a/includes/SpecialWatchlist.php b/includes/SpecialWatchlist.php index 5f3f2be535..3d14b2a4d2 100644 --- a/includes/SpecialWatchlist.php +++ b/includes/SpecialWatchlist.php @@ -27,8 +27,7 @@ function wfSpecialWatchlist() { $specialTitle = Title::makeTitle( NS_SPECIAL, 'Watchlist' ); - $uid = $wgUser->getID(); - if( $uid == 0 ) { + if( $wgUser->isAnon() ) { $wgOut->addWikiText( wfMsg( 'nowatchlist' ) ); return; } @@ -52,6 +51,7 @@ function wfSpecialWatchlist() { "\n\n" ); } + $uid = $wgUser->getID(); if( $wgRequest->getVal( 'reset' ) == 'all' ) { $wgUser->clearAllNotifications( $uid ); } diff --git a/languages/LanguageZh.php b/languages/LanguageZh.php index 7c2cab1fa1..bdefc3ac38 100644 --- a/languages/LanguageZh.php +++ b/languages/LanguageZh.php @@ -224,7 +224,7 @@ class LanguageZh extends LanguageZh_cn { } // get language variant preference from logged in users - if($wgUser->getID()!=0) { + if( $wgUser->isLoggedIn() ) { $this->mZhLanguageCode = $wgUser->getOption('variant'); } diff --git a/skins/CologneBlue.php b/skins/CologneBlue.php index 7cf5b28365..06e5d46612 100644 --- a/skins/CologneBlue.php +++ b/skins/CologneBlue.php @@ -25,7 +25,7 @@ class SkinCologneBlue extends Skin { } function doBeforeContent() { - global $wgUser, $wgOut, $wgTitle, $wgSiteNotice; + global $wgOut, $wgTitle, $wgSiteNotice; $s = ""; $qb = $this->qbSetting(); @@ -67,7 +67,7 @@ class SkinCologneBlue extends Skin { function doAfterContent() { - global $wgUser, $wgOut; + global $wgOut; $s = "\n
\n"; @@ -96,9 +96,9 @@ class SkinCologneBlue extends Skin { if ( 0 != $qb ) { $s .= $this->quickBar(); } return $s; } - function doGetUserStyles() - { - global $wgUser, $wgOut, $wgStyleSheetPath; + + function doGetUserStyles() { + global $wgOut, $wgStyleSheetPath; $s = parent::doGetUserStyles(); $qb = $this->qbSetting(); @@ -116,8 +116,8 @@ class SkinCologneBlue extends Skin { } return $s; } - function sysLinks() - { + + function sysLinks() { global $wgUser, $wgContLang, $wgTitle; $li = $wgContLang->specialPage("Userlogin"); $lo = $wgContLang->specialPage("Userlogout"); @@ -140,12 +140,9 @@ class SkinCologneBlue extends Skin { . " | " . $this->specialLink( "specialpages" ) . " | "; - if ( $wgUser->getID() ) - { + if ( $wgUser->isLoggedIn() ) { $s .= $this->makeKnownLink( $lo, wfMsg( "logout" ), $q ); - } - else - { + } else { $s .= $this->makeKnownLink( $li, wfMsg( "login" ), $q ); } @@ -200,7 +197,7 @@ class SkinCologneBlue extends Skin { $s .= $sep . $this->makeKnownLink( wfMsgForContent( "edithelppage" ), wfMsg( "edithelp" ) ); - if ( 0 != $wgUser->getID() ) { + if( $wgUser->isLoggedIn() ) { $s .= $sep . $this->moveThisPage(); } if ( $wgUser->isAllowed('delete') ) { @@ -221,7 +218,7 @@ class SkinCologneBlue extends Skin { $s .= $this->talkLink() . $sep . $this->commentLink() . $sep . $this->printableLink(); - if ( 0 != $wgUser->getID() ) { + if ( $wgUser->isLoggedIn() ) { $s .= $sep . $this->watchThisPage(); } @@ -245,7 +242,7 @@ class SkinCologneBlue extends Skin { } $s .= $this->menuHead( "qbmyoptions" ); - if ( 0 != $wgUser->getID() ) { + if ( $wgUser->isLoggedIn() ) { $name = $wgUser->getName(); $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsg( 'mytalk' ) ); diff --git a/skins/Nostalgia.php b/skins/Nostalgia.php index d29aaf8f65..02b5d8b2c1 100644 --- a/skins/Nostalgia.php +++ b/skins/Nostalgia.php @@ -66,7 +66,7 @@ class SkinNostalgia extends Skin { $s .= $sep . $this->editThisPage() . $sep . $this->historyLink(); } - if ( 0 == $wgUser->getID() ) { + if ( $wgUser->isAnon() ) { $s .= $sep . $this->specialLink( "userlogin" ); } else { $s .= $sep . $this->specialLink( "userlogout" ); @@ -77,8 +77,6 @@ class SkinNostalgia extends Skin { } function doAfterContent() { - global $wgUser, $wgOut; - $s = "\n
\n"; $s .= "\n